package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.authorizeRFCPanel.authorizeRFCPanelSubs.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.RFC;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.authorizeRFCPanel.AuthorizeRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.authorizeRFCPanel.authorizeRFCPanelSubs.AuthoriseRFCDialog;

public class ShowRFCButtonListener extends MouseAdapter implements
		ActionListener {

	private AuthorizeRFCPanel authorizeRFCPanel;

	public ShowRFCButtonListener(AuthorizeRFCPanel authorizeRFCPanel) {
		this.authorizeRFCPanel = authorizeRFCPanel;
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		this.actionEvet();

	}

	@Override
	public void mouseClicked(MouseEvent arg0) {

		if (arg0.getClickCount() == 2) {
			this.actionEvet();
		}
	}

	private void actionEvet() {
		RFC rfc = authorizeRFCPanel.getListPanel().getDisplayTable()
				.getSelectedRFCinTable();

		if (rfc != null) {

			new AuthoriseRFCDialog(authorizeRFCPanel, rfc);
		}
	}
}
